#pragma once
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <torch/script.h>
#include <torch/torch.h>
#include <QDate>
#include <QTimer>
#include "ui_mainwindow.h"
#include "opencv2/opencv.hpp"

#include "imageshow.h"

class mainwindow : public QMainWindow
{
    Q_OBJECT
    cv::VideoCapture capture;
public:
    mainwindow(QWidget* parent = nullptr);
    void initPlayer();
    void init_Form();
    void init_torch(const std::string& modelpath);
    std::shared_ptr<QTimer> Sys_timer;
    std::shared_ptr<QTimer> frametimer;
    std::shared_ptr<QTimer> snaptimer;
    void on_btnVideo_clicked() const;
    
private slots:
    void on_btnSnap_clicked();
    void ready2takeshot();
    void on_btnInspect_clicked() const;
private:
	 std::vector<std::string> classes{ "person", "bicycle", "car", "motorcycle", "airplane", "bus", "train", "truck", "boat", "traffic light", "fire hydrant",
                                     "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse", "sheep", "cow", "elephant", "bear", "zebra",
                                     "giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee", "skis", "snowboard", "sports ball", "kite",
                                     "baseball bat", "baseball glove", "skateboard", "surfboard", "tennis racket", "bottle", "wine glass", "cup", "fork", "knife",
                                     "spoon", "bowl", "banana", "apple", "sandwich", "orange", "broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair",
                                     "couch", "potted plant", "bed", "dining table", "toilet", "tv", "laptop", "mouse", "remote", "keyboard", "cell phone",
                                     "microwave", "oven", "toaster", "sink", "refrigerator", "book", "clock", "vase", "scissors", "teddy bear", "hair drier", "toothbrush" };
    Ui::MainWindow ui;
    void setTimerLabel() const;
    void nextFrame();
    std::shared_ptr<QLabel> sysInfo;
    int framerate;
    int channels;
    torch::Device device = torch::Device(torch::kCUDA);
    torch::jit::script::Module torch_module;
    cv::Mat frame;
    cv::Mat rgb;
    cv::Mat rezie;
    QSize m_videolabelSize;
    std::shared_ptr<QImage> bufferimg;
    std::shared_ptr<imageshow> imgshow;
    bool ready2take = false;
};
#endif
